home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group00b.txt / 000107_icon-group-sender_Wed Oct 25 08:08:53 2000.msg < prev    next >
Internet Message Format  |  2001-01-03  |  2KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id e9PF8eP09361
  4.     for icon-group-addresses; Wed, 25 Oct 2000 08:08:40 -0700 (MST)
  5. Message-Id: <200010251508.e9PF8eP09361@baskerville.CS.Arizona.EDU>
  6. Date: Tue, 24 Oct 2000 17:30:29 -0700 (PDT)
  7. From: Shamim Mohamed <shamim@drones.com>
  8. To: "Charles Hethcoat" <CHETHCOA@oss.oceaneering.com>
  9. Cc: <icon-group@cs.arizona.edu>
  10. Subject: Re: How to "declare" a string?
  11. Errors-To: icon-group-errors@cs.arizona.edu
  12. Status: RO
  13. Content-Length: 1427
  14.  
  15. Charles Hethcoat replies to someone's question:
  16.  > 
  17.  > > So again I'm back to the quesiton, "How to 'declare' a string variable?"
  18.  > 
  19.  > I don't know if this will help answer the question, which I am
  20.  > admittedly quite confused about.  However, a few smart tests can take
  21.  > you far.
  22.  
  23. Actually, an attentive reading of Griswold and Griswold will help more
  24. than running tests; that way you don't have to try to figure out what
  25. the language is doing, the book tells you exactly what's happening.
  26.  
  27.  > ... my guess is that the line 
  28.  > 
  29.  > s2[2] := s1
  30.  > 
  31.  > is ambiguous.  s2 could be a string OR a table.  Either one would be
  32.  > syntactically correct. 
  33.  
  34. I fear you are getting too hung up on syntax. When icont sees s2[2], it
  35. generates instructions for the interpreter iconx: "apply the subscript
  36. operator to the value stored in the variable s2 with the index 2". And
  37. what value is stored in s2 when execution reaches that line? The null
  38. value &null, which cannot accept a subscript operation. Ergo runtime
  39. error. Remember, icont does not do the type-checking, iconx does.
  40. (Values that the subscript operator [] can be applied to are: strings,
  41. csets, lists, tables, ...)
  42.  
  43. To the original writer: don't think too much about types of variables.
  44. That is an artifact of languages like C or Pascal. Think about values
  45. having types, variables are just pigeonholes for these typed values. A
  46. variable can hold a value of any type.
  47.  
  48. -s
  49.